#ifndef INCLUDE_MultithreadingCP
#define INCLUDE_MultithreadingCP
// multithreading cross paltform setting
#ifdef WIN32
#include <windows.h>
#include <process.h>
typedef HANDLE CP_MUTEXLOCK; // the mutex lock variable type
#define CreatMutexCP() CreateMutex(NULL, FALSE, NULL)
#define WaitMutexCP(hMutex) WaitForSingleObject(hMutex, INFINITE)
#define ExitMutexCP(hMutex) ReleaseMutex(hMutex)
#define DelayCP(msecond) Sleep(msecond)
#define CreatThreadCP(ThreadFun) _beginthreadex(NULL, 0, ThreadFun, NULL, 0, NULL);
#else
// LINUX OR OTHER SYSTEM
#define __stdcall 
#include <pthread.h>
#include <unistd.h>
typedef pthread_mutex_t CP_MUTEXLOCK; // the mutex lock variable type
CP_MUTEXLOCK CreatMutexCP()
{
	CP_MUTEXLOCK mlock;
	pthread_mutex_init(&mlock, NULL);
	return mlock;
}

#define WaitMutexCP(hMutex) pthread_mutex_lock(&hMutex)
#define ExitMutexCP(hMutex) pthread_mutex_unlock(&hMutex)
#define DelayCP(msecond) usleep(msecond * 1000)
// #define CreatThreadCP(ThreadFun) pthread_create()

#endif // WIN32

#endif // !INCLUDE_MultithreadingCP

